Skip to content

fix(cli): align strict missing semantics with extract#2512

Open
yslpn wants to merge 7 commits intolingui:mainfrom
yslpn:fix/strict-missing-semantics
Open

fix(cli): align strict missing semantics with extract#2512
yslpn wants to merge 7 commits intolingui:mainfrom
yslpn:fix/strict-missing-semantics

Conversation

@yslpn
Copy link
Copy Markdown
Contributor

@yslpn yslpn commented Apr 13, 2026

Description

This change makes missing-translation validation configurable while preserving the existing Lingui 6 behavior by default.

It closes issue #2506.

Previously, the proposed fix changed compile --strict and bundler failOnMissing semantics to validate raw target catalog entries before fallbackLocales were applied. That matched extract missing counts, but it would now be a breaking change for users who rely on fallback-resolved catalogs passing strict validation.

With this change:

  • compile --strict keeps the existing resolved behavior and still fails on message compilation errors.
  • compile --fail-on-missing resolved fails only when translations are still missing after fallbackLocales are applied.
  • compile --fail-on-missing catalog fails when the target locale catalog itself has missing translations before fallbackLocales are applied.
  • compile --strict --fail-on-missing catalog combines catalog-level missing validation with compilation error validation.
  • webpack loader and Vite plugin failOnMissing: true keep the existing resolved behavior.
  • webpack loader and Vite plugin failOnMissing: "resolved" and failOnMissing: "catalog" provide explicit missing-validation modes.
  • fallback resolution for compiled output is unchanged in every mode.

This gives teams a non-breaking way to opt into catalog-level missing validation, while keeping current --strict and failOnMissing: true behavior compatible with existing projects.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Fixes #2506

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@yslpn yslpn changed the base branch from main to next April 13, 2026 15:57
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

@yslpn is attempting to deploy a commit to the Crowdin Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 80.70175% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.27%. Comparing base (6bb8983) to head (0c61b70).
⚠️ Report is 329 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/lingui-compile.ts 20.00% 7 Missing and 1 partial ⚠️
packages/cli/src/api/messages.ts 90.00% 1 Missing ⚠️
packages/loader/src/webpackLoader.ts 91.66% 1 Missing ⚠️
packages/vite-plugin/src/index.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2512       +/-   ##
===========================================
+ Coverage   77.05%   89.27%   +12.22%     
===========================================
  Files          84      118       +34     
  Lines        2157     3421     +1264     
  Branches      555     1026      +471     
===========================================
+ Hits         1662     3054     +1392     
+ Misses        382      331       -51     
+ Partials      113       36       -77     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview May 1, 2026 10:54am

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the definition of “missing translations” across lingui extract, lingui compile --strict, and bundler integrations (failOnMissing) so that strict checks are based on raw missing entries in the target locale catalog (ignoring fallbackLocales), while compiled output fallback behavior remains unchanged. This addresses issue #2506.

Changes:

  • Introduces missingBehavior: "catalog" to count missing translations based on the target locale’s catalog entries (not post-fallback resolution).
  • Updates CLI compile flow + webpack loader + Vite plugin to use the new missing semantics for strict/fail-on-missing validation.
  • Adds regression tests/fixtures for CLI, webpack loader, and Vite plugin; updates CLI docs wording.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/docs/ref/cli.md Updates compile --strict documentation to describe pre-fallbackLocales missing semantics.
packages/cli/src/lingui-compile.ts Updates CLI --strict option description text.
packages/cli/src/api/compile/compileLocale.ts Forces strict missing detection to use raw catalog semantics via missingBehavior: "catalog".
packages/cli/src/api/catalog/getTranslationsForCatalog.ts Adds missingBehavior option and implements raw-vs-resolved missing detection.
packages/cli/src/api/catalog/getTranslationsForCatalog.test.ts Adds test coverage for raw missing detection even when fallbacks resolve.
packages/cli/src/test/compile.test.ts Adds CLI regression test for strict failure despite fallback resolution.
packages/cli/src/test/snapshots/compile.test.ts.snap Updates snapshots impacted by the changed strict/missing semantics.
packages/loader/src/webpackLoader.ts Aligns loader failOnMissing behavior with raw catalog missing semantics.
packages/loader/test/loader.test.ts Adds loader regression test for fallback-resolved but raw-missing translations.
packages/loader/test/fail-on-missing-fallback/** Adds loader fixture catalogs/config for fallback-missing scenario.
packages/vite-plugin/src/index.ts Aligns Vite plugin failOnMissing behavior with raw catalog missing semantics.
packages/vite-plugin/test/vite-plugin.test.ts Adds Vite regression test for fallback-resolved but raw-missing translations (and adjusts timeouts).
packages/vite-plugin/test/fail-on-missing-fallback/** Adds Vite fixture catalogs/config for fallback-missing scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/docs/ref/cli.md Outdated
Comment thread packages/cli/src/lingui-compile.ts Outdated
Comment thread packages/cli/src/api/catalog/getTranslationsForCatalog.ts Outdated
yslpn and others added 2 commits April 14, 2026 23:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@timofei-iatsenko
Copy link
Copy Markdown
Collaborator

Since this wasn't released with v6, and it is a breaking change now, i propose to make it non-breaking by hiding behind a feature flag. You can use current strict flag, or add a more dedicated such as --failOnMissing with options to cli.

WDYT?

@yslpn
Copy link
Copy Markdown
Contributor Author

yslpn commented Apr 29, 2026

Since this wasn't released with v6, and it is a breaking change now, i propose to make it non-breaking by hiding behind a feature flag. You can use current strict flag, or add a more dedicated such as --failOnMissing with options to cli.

WDYT?

Then I think I'll add two modes with this interface:

// CLI
--strict                         // resolved + compile errors
--fail-on-missing resolved       // resolved only
--fail-on-missing catalog        // catalog only
--strict --fail-on-missing catalog  // catalog + compile errors
--strict --fail-on-missing resolved  // resolved + compile errors

// webpack / vite
failOnMissing: true              // resolved
failOnMissing: "resolved"        // resolved
failOnMissing: "catalog"         // catalog

@yslpn yslpn marked this pull request as draft April 29, 2026 20:45
@yslpn yslpn marked this pull request as ready for review May 1, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lingui compile --strict semantics do not match extract "Missing"

4 participants